﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GameThree
{
    public class GraphicsDrawable : IDrawable
    {
        /// <summary>
        /// +1集合 绘制6次移除
        /// </summary>
        public List<DrawItem> DrawItems;
        public GraphicsDrawable()
        {
            DrawItems = new List<DrawItem>();
        }
        public void Draw(ICanvas canvas, RectF dirtyRect)
        {
            //有+1才绘制
            if (DrawItems.Count > 0)
            {
                foreach (DrawItem item in DrawItems)
                {
                    //起始高
                    float y = dirtyRect.Height / 4;
                    //减去绘制次数的倍数的距离
                    y -= item.DrwaCount * 10;
                    canvas.DrawString(item.DrawText, dirtyRect.Width / 2, y, HorizontalAlignment.Center);
                    item.DrwaCount++;
                }
                //移除绘制超过6次的项
                var delitem = DrawItems.Find(x => x.DrwaCount > 6);
                DrawItems.Remove(delitem);
            }

        }
    }
    public class DrawItem
    {
        /// <summary>
        /// 绘制次数
        /// </summary>
        public int DrwaCount { get; set; }
        /// <summary>
        /// 绘制文本
        /// </summary>
        public string DrawText { get; set; }
    }
}
